<template>
  <el-button
    size="mini"
    type="danger"
    @click="handleResetPassword"
  >重置密码</el-button>
</template>

<script>
// import { resetPassword } from '@/svc/account'

export default {
  name: 'ResetPassword',
  props: {
    fnEdit: { type: Function, default: null },
    info: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  methods: {
    handleResetPassword() {
      this.$confirm('确定要重置[' + this.info.loginId + ']的密码吗？', '确认', {
        distinguishCancelAndClose: true,
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(() => {
        this.fnEdit(this, { id: this.info.id }).then(res => {
          if (res) {
            this.$success('重置成功' + res)
            this.$emit('onPasswordReset', { id: this.info.id, password: res })
          }
        })
      }).catch(() => {})
    }
  }
}
</script>

<style scoped>

</style>
